package com.qf.day4.work;

import java.util.Arrays;
import java.util.Scanner;

public class Work1 {
    /**
     *
     * @param num 数字
     * @return boolean值 判断是否回文
     */
    public static Boolean palindromeNum(int num) {
        String str = Integer.toString(num);
        char[] array = str.toCharArray();
        int len = array.length-1;
        for (int i = 0; i < array.length/2; i++) {
            if(!(array[i]==array[len])){
                //前后字符不相等
                return false;
            }
            len--;
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入不大于八位的数字：");
        int num = scanner.nextInt();
        if(Integer.toString(num).length()<8){
            if(palindromeNum(num)){
                System.out.println("回文");
            }else{
                System.out.println("不是回文");
            }
        }else {
            System.out.println("输入有误: 您输入了"+Integer.toString(num).length()+"位的数字");
        }


    }
}
